{% load static %}
<!DOCTYPE html>
<html lang="zh">

<head>
<meta charset="utf-8" />
<title>登录</title>
<link rel="stylesheet" type="text/css" href="../static/managelogin/css/index.css" />
<script src="{% static "bootstrap-4.6.0-dist/js/jquery-3.5.1.min.js" %}"></script>
</head>
<style>
    .msg{
        position: absolute;
        top: 18.5rem;
        left: 33rem;
    }
</style>
<body>
<img class="bgone" src="../static/managelogin/img/1.jpg" />
<img class="pic" src="../static/managelogin/img/a.png" />
<div class="table">
	<div class="wel">影院管理者后台登录</div>
	<div class="wel1">YING YUAN GUAN LI ZHE HUO TAI DENG LU</div>
	<div class="user">
		<div id="yonghu" style=""><img src="../static/managelogin/img/yhm.png" /></div>
		<input id="manager_account" type="text" name="" placeholder="用户名" />
	</div>			
	<div class="password">
		<div id="yonghu"><img src="../static/managelogin/img/mm.png" /></div>
		<input id ="manager_pawd" type="password" name="密码" placeholder="●●●●●●"/>
	</div>
    <div class = "msg"><strong>提示信息:</strong><a id = "login_msg" style="color: darkred;font-weight: bold;margin-left: 1rem;"></a> </div>
    <div class="btn" type="button" onclick="submit_log()">登录</div>
</div>
<script>
    function submit_log(){
        account = $("#manager_account").val()
        password = $("#manager_pawd").val()
        if(account===""||password==="")
        {
            $("#login_msg").text("账号或密码不能为空")
        }
        else{
            var form = new FormData();
            form.append("account",account);
            form.append("password",password);
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: window.location.href ,//url
                processData: false,
                async:false,
                data: form,
                contentType: false,
                success: function (result) {
                    if(result['msg'] ==="登录成功"){
                        window.location.href = window.location.href+result['href']
                    }
                    else{
                        $("#login_msg").text(result['msg'])
                    }
                },
                error : function(result) {
                    $("#login_msg").text("网络错误")
                }
            });
        }
    }
</script>
</body>
</html>